function DemoController(
    initialList,//路由中预加载数据的注入
    Stream,
    Sorter,
    Demo,
    $uibModal,
    $log,
    $scope,
    $state,
    $stateParams
) {
    var vm = this

    initialList.$promise.then(function(response) {
        // 将后台返回的数据填充
        vm.users=response.content

        // 是否显示分页
        vm.isLoaded = true;
        vm.queryParams = _.clone($stateParams)
        vm.totalItems = response.totalElements
        vm.totalPages = response.totalPages
    })


    // 点击delete事件调用该函数
    vm.delete = function(user) {
        // 模拟窗口打开之后执行该函数
        var modalInstance = $uibModal.open({
            templateUrl: 'myModalContent.html',
            controller: 'ModalInstanceCtrl',
            size: user
        });

        // 模拟窗口关闭后回传调用
        modalInstance.result.then(function (selectedItem) {
            if(selectedItem == 'ok') {
                Demo.delete({
                    id : user.id
                }).$promise.then(function(){
                    $state.reload($state.current)
                })
            }
        });
    }

    // 去除查询条件
    vm.reset = function(parameter) { vm.queryParams = {}; }

    // 查询调用
    vm.search = function() {
        $state.go($state.current, vm.queryParams)
    }

    vm.register = function() {
        $state.go('userAdd' , vm.queryParams)
    }

    vm.update = function(user) {
        $state.go('userUpdate' , {'id':user.id,'user_name':user.user_name})
    }
}

